package cn.wolfcode.luowowo.scenic.service.impl;

import cn.wolfcode.luowowo.common.query.ScenicDetailQueryObject;
import cn.wolfcode.luowowo.scenic.domain.ScenicDetail;
import cn.wolfcode.luowowo.scenic.mapper.ScenicDetailMapper;
import cn.wolfcode.luowowo.scenic.mapper.TicketDetailMapper;
import cn.wolfcode.luowowo.scenic.service.IScenicDetailService;
import cn.wolfcode.luowowo.scenic.service.ITicketDetailService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class ScenicDetailServiceImpl implements IScenicDetailService {
    @Autowired
    private ScenicDetailMapper scenicDetailMapper;
    @Autowired
    private TicketDetailMapper ticketDetailMapper;

    public ScenicDetail getByDestId(Long destId) {
        return scenicDetailMapper.selectByDestId(destId);
    }

    public List<ScenicDetail> listTop5ByDestId(Long destId) {
        return scenicDetailMapper.selectTop5ByDestId(destId);
    }


    public ScenicDetail get(Long id) {
        ScenicDetail scenicDetail = scenicDetailMapper.selectByPrimaryKey(id);
        //获取门票信息
        // ticketDetailMapper.selectByTicketId(scenicDetail.getTicket().getId());
        return scenicDetail;
    }


    public PageInfo<ScenicDetail> listByThemeId(ScenicDetailQueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(), qo.getPageSize());
        List<ScenicDetail> list = scenicDetailMapper.selectByThemeId(qo.getThemeId(), qo.getDestId());
        return new PageInfo<>(list);

    }


    public List<ScenicDetail> listHotScenicsByDestId(Long destId) {
        return scenicDetailMapper.selectHotScenicsByDestId(destId);
    }

    public List<ScenicDetail> listCommendByTicketId(Long tid) {
        return scenicDetailMapper.selectCommendByTicketId(tid);
    }
}
